<?php

namespace Lib\File;

class File {
	private $_aScheme = array (
			'http',
			'ftp' 
	);
	private $_sType = 'Filesys';

	public function __call($sName, $aParam) {
		$sType = $this->_sType;
		require_once __DIR__ . '/' . $sType . '.class.php';
		$sClass = __NAMESPACE__ . '\\' . $sType;
		$oClass = new $sClass ();
		return call_user_func_array ( array (
				$oClass,
				$sName 
		), $aParam );
	}

	public function setType($sType = 'Filesys') {
		$this->_sType = ucfirst ( strtolower ( $sType ) );
	}

	public function __get($sName) {
		if (! $this->$sName) {
			$this->init ();
		}
		return $this->$sName;
	}

	public function __set($sName, $sValue) {
		$this->$sName = $sValue;
	}

	public function getContents($sFile, $sType = null) {
		$aInfo = parse_url ( $sFile );
		if (! in_array ( $aInfo ['scheme'], $this->_aScheme )) {
			return $this->__call ( 'getContents', array (
					$sFile,
					$sType 
			) );
		}
	}
}

?>